package com.hx.jdk7;

import org.checkerframework.checker.units.qual.K;

/**
 * @author minghuaChan
 * @since 2023/6/24 12:01
 */
public class MyMap {
    public static void main(String[] args) {
        NodeItem[] arr = new NodeItem[2];

        NodeItem item1 = new NodeItem();
        item1.setValue("3");

        NodeItem item2 = new NodeItem();
        item2.setValue("7");

        NodeItem item3 = new NodeItem();
        item3.setValue("9");

        item1.setNext(item2);
        item2.setNext(item3);

        arr[0] = item1;


        NodeItem[] newArr = new NodeItem[4];

        Thread t1 = new Thread(() ->{
            transfer(arr,newArr);
        });

        Thread t2 = new Thread(() ->{
            transfer(arr,newArr);
        });

        t1.start();
        t2.start();


        System.out.println("done");

    }


    //扩容后将数据填充进新桶
    public static void transfer(NodeItem[] arr, NodeItem[] newArr) {
        for (NodeItem e : arr) {
            while (null != e) {
                NodeItem next = e.getNext();
                // 执行到这行停顿
                e.setNext(newArr[2]);
                newArr[2] = e;
                e = next;
            }
        }
    }


}
